<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
	Object obj = request.getSession().getAttribute("role_resource");
	if (null == obj) {
		response.setStatus(1000);
		return;
	}
%>

		<script type="text/javascript">
		//用户参数列表数据源
		var code_store  = new Ext.data.JsonStore( {
			root : "data",
			totalProperty : "Total",
			fields : [ "period", "filename", "epibolyno","share","starttime","endtime","cardid","paperno","state","personno","billfilename","cardName","businpntName","paperName","loginName" ],//
			url : "work!queryXmlLog.action"
		});
		//账单类型数据源
		var billType = new Ext.data.JsonStore( {
			fields: ["id","text"],
			data: [{id:'',text:'全部'},{id:'1',text:'纸质'},{id:'2',text:'电子'}]
		});
		//账单状态数据源
		var state_type = new Ext.data.JsonStore( {
			fields: ["id","text"],//状态,0xml生成失败1xml生成成功2xml生成生成中3账单生成中4账单生成失败5账单生成成功6账单生成已过滤
			data: [{id:'0',text:'xml生成失败'},{id:'1',text:'xml生成成功'},{id:'2',text:'xml生成生成中'},{id:'3',text:'账单生成中'}
			,{id:'4',text:'账单生成失败'},{id:'5',text:'账单生成成功'},{id:'6',text:'账单生成已过滤'}]
		});
		
		//定义数据显示面板
		var dirGrid = {
			id : "dirGrid",
			//title : "合成XML_Log数据列表",
			region : "center",
			xtype : "grid",
			border:true,
			stripeRows : true,
			loadMask : true,
			autoWidth : true,
			autoExpandColumn : "filename",
			autoExpandMin : 100,
			store : code_store,
			headersDisabled: true,
			columns : [ new Ext.grid.RowNumberer( {
				header : "序号",
				width : 50
			}), {
				header : "账期",
				dataIndex : "period",
				menuDisabled: true
			}, {
				header : "XML文件名",
				dataIndex : "filename",
				id : "filename",
				menuDisabled: true
			}, {
				header : "外包商",
				dataIndex : "businpntName",
				width : 100,
				menuDisabled: true
			}, {
				header : "账单份数",
				dataIndex : "share",
				width : 50,
				menuDisabled: true
			}, {
				header : "开始时间",
				dataIndex : "starttime",
				width: 120,
				menuDisabled: true
			}, {
				header : "结束时间",
				dataIndex : "endtime",
				width: 120,
				menuDisabled: true
			}, {
				header : "卡产品",
				dataIndex : "cardName",
				menuDisabled: true
			}, {
				header : "预印纸",
				dataIndex : "paperName",
				width: 55,
				menuDisabled: true
			}, {
				header : "状态",
				dataIndex : "state",
				menuDisabled: true,
				renderer : function(input) {
					var res1 = state_type.getById(input);
					return (res1)?res1.data.text:"";
				}
			}, {
				header : "操作人",
				dataIndex : "loginName",
				width: 80,
				menuDisabled: true
			}, {
				header : "账单文件名",
				dataIndex : "billfilename",
				menuDisabled: true
			}, {
				xtype : "billActionColumn",
				header : "下载",
				width : 50,
				dataIndex : "state",
				menuDisabled: true,
				items : [{
					icon:'images/information.png',
					tooltip:'下载',
					handler: function(grid, rowIndex, colIndex){
						var res = code_store.getAt(rowIndex);
						var url = "download.action?id="+res.get('billfilename')+"&onLine=false";
						//var winparams="height=150, width=266, top=250, left=500, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no";
						window.open (url);
					}
				}],
				renderer : function(input) {
					return "5"==input;
				}
			}],
			tbar : [{
				xtype : 'label',
				text : '账单类型'
			},{
				xtype : 'billCombox',
				id : 'selecttype',
				width : 100,
				text : '查询条件',
				valueField : 'id',
				displayField : 'text',
				store : billType,
				listeners : {
					'select' : function() {
						code_store.load({params : {start:0,limit:limit,"typeflag": this.value}});
					}
				}
			}],
			bbar : new Ext.ux.PagingToolbar( {
				pageSize : limit,
				store : code_store
			})
		};
		var uploadForm = new Ext.Panel({
			id : "uploadForm",
			region : "north",
			title : "文件上传",
			fileUpload : true,
			frame : true,
			autoHeight: true,
			collapsible: true,
			bodyStyle : "padding: 10px 10px 10px 10px;",
			items : [ {
					xtype : "fieldset",
					title : "V+数据上传",
					layout : "column",
					items : [ {
						columnWidth : .4,
						id : "A001",
						xtype : "form",
						fileUpload : true,
						labelWidth: 125,
						layout : "form",
						items : [ {
							id : "A001selectFile",
							fieldLabel : "客户记录A001",
							xtype : "fileuploadfield",
							emptyText : "请选择文件",
							name : "file",
							anchor : "95%"
						}, {
							xtype : "textfield",
							name : "type",
							hidden : true,
							value : "A001"
						} ]
					}, {
						columnWidth : .1,
						layout : "form",
						items : [ {
							xtype : "button",
							text : "上传文件",
							handler : function() {
								var vA = Ext.getCmp("A001selectFile").getValue();
								if(''==vA){
									Ext.Msg.show({
										title: "Selected File",
							            msg: vA&&vA!='' ? vA:'未选择文件!',
							            minWidth: 200,
							            modal: true,
							            icon: Ext.Msg.INFO,
							            buttons: Ext.Msg.OK
									});
									return;
								}else{
									if (Ext.getCmp("A001").getForm().isValid()) {
										Ext.getCmp("A001").getForm().submit( {
											url : "upload2.action",
											waitMsg : "正在上传文件...",
											success : function(fp, o) {
												Ext.Msg.show( {
													title : "Success",
													msg : "文件上传成功！",
													minWidth : 200,
													modal : true,
													icon : Ext.Msg.INFO,
													buttons : Ext.Msg.OK
												});
											}
										});
									}
								}
							}
						} ]
					}, {
						columnWidth : .4,
						id : "B001",
						xtype : "form",
						fileUpload : true,
						labelWidth: 125,
						layout : "form",
						items : [ {
							id : "B001selectFile",
							fieldLabel : "人民币汇总B001",
							xtype : "fileuploadfield",
							emptyText : "请选择文件",
							name : "file",
							anchor : "95%"
						}, {
							xtype : "textfield",
							name : "type",
							hidden : true,
							value : "B001"
						} ]
					}, {
						columnWidth : .1,
						layout : "form",
						items : [ {
							xtype : "button",
							text : "上传文件",
							handler : function() {
								var vB = Ext.getCmp("B001selectFile").getValue();
								if(''==vB){
									Ext.Msg.show({
										title: "Selected File",
							            msg: vB&&vB!='' ? vB:'未选择文件!',
							            minWidth: 200,
							            modal: true,
							            icon: Ext.Msg.INFO,
							            buttons: Ext.Msg.OK
									});
									return;
								}else{
									if (Ext.getCmp("B001").getForm().isValid()) {
										Ext.getCmp("B001").getForm().submit( {
											url : "upload2.action",
											waitMsg : "正在上传文件...",
											success : function(fp, o) {
												Ext.Msg.show( {
													title : "Success",
													msg : "文件上传成功！",
													minWidth : 200,
													modal : true,
													icon : Ext.Msg.INFO,
													buttons : Ext.Msg.OK
												});
											}
										});
									}
								}
							}
						} ]
					}, {
						columnWidth : .4,
						id : "F001",
						xtype : "form",
						fileUpload : true,
						labelWidth: 125,
						layout : "form",
						items : [ {
							id : "F001selectFile",
							fieldLabel : "购汇信息F001",
							xtype : "fileuploadfield",
							emptyText : "请选择文件",
							name : "file",
							anchor : "95%"
						}, {
							xtype : "textfield",
							name : "type",
							hidden : true,
							value : "F001"
						} ]
					}, {
						columnWidth : .1,
						layout : "form",
						items : [ {
							xtype : "button",
							text : "上传文件",
							handler : function() {
								var vF = Ext.getCmp("F001selectFile").getValue();
								if(''==vF){
									Ext.Msg.show({
										title: "Selected File",
							            msg: vF&&vF!='' ? vF:'未选择文件!',
							            minWidth: 200,
							            modal: true,
							            icon: Ext.Msg.INFO,
							            buttons: Ext.Msg.OK
									});
									return;
								}else{
									if (Ext.getCmp("F001").getForm().isValid()) {
										Ext.getCmp("F001").getForm().submit( {
											url : "upload2.action",
											waitMsg : "正在上传文件...",
											success : function(fp, o) {
												Ext.Msg.show( {
													title : "Success",
													msg : "文件上传成功！",
													minWidth : 200,
													modal : true,
													icon : Ext.Msg.INFO,
													buttons : Ext.Msg.OK
												});
											}
										});
									}
								}
							}
						} ]
					}, {
						columnWidth : .4,
						id : "C001",
						xtype : "form",
						fileUpload : true,
						labelWidth: 125,
						layout : "form",
						items : [ {
							id : "C001selectFile",
							fieldLabel : "人民币汇总明细C001",
							xtype : "fileuploadfield",
							emptyText : "请选择文件",
							name : "file",
							anchor : "95%"
						}, {
							xtype : "textfield",
							name : "type",
							hidden : true,
							value : "C001"
						} ]
					}, {
						columnWidth : .1,
						layout : "form",
						items : [ {
							xtype : "button",
							text : "上传文件",
							handler : function() {
								var vC = Ext.getCmp("C001selectFile").getValue();
								if(''==vC){
									Ext.Msg.show({
										title: "Selected File",
							            msg: vC&&vC!='' ? vC:'未选择文件!',
							            minWidth: 200,
							            modal: true,
							            icon: Ext.Msg.INFO,
							            buttons: Ext.Msg.OK
									});
									return;
								}else{
									if (Ext.getCmp("C001").getForm().isValid()) {
										Ext.getCmp("C001").getForm().submit( {
											url : "upload2.action",
											waitMsg : "正在上传文件...",
											success : function(fp, o) {
												Ext.Msg.show( {
													title : "Success",
													msg : "文件上传成功！",
													minWidth : 200,
													modal : true,
													icon : Ext.Msg.INFO,
													buttons : Ext.Msg.OK
												});
											}
										});
									}
								}
							}
						} ]
					}, {
						columnWidth : .4,
						id : "C002",
						xtype : "form",
						fileUpload : true,
						labelWidth: 125,
						layout : "form",
						items : [ {
							id : "C002selectFile",
							fieldLabel : "人民币交易明细C002",
							xtype : "fileuploadfield",
							emptyText : "请选择文件",
							name : "file",
							anchor : "95%"
						}, {
							xtype : "textfield",
							name : "type",
							hidden : true,
							value : "C002"
						} ]
					}, {
						columnWidth : .1,
						layout : "form",
						items : [ {
							xtype : "button",
							text : "上传文件",
							handler : function() {
								var vC2 = Ext.getCmp("C002selectFile").getValue();
								if(''==vC2){
									Ext.Msg.show({
										title: "Selected File",
							            msg: vC2&&vC2!='' ? vC2:'未选择文件!',
							            minWidth: 200,
							            modal: true,
							            icon: Ext.Msg.INFO,
							            buttons: Ext.Msg.OK
									});
									return;
								}else{
									if (Ext.getCmp("C002").getForm().isValid()) {
										Ext.getCmp("C002").getForm().submit( {
											url : "upload2.action",
											waitMsg : "正在上传文件...",
											success : function(fp, o) {
												Ext.Msg.show( {
													title : "Success",
													msg : "文件上传成功！",
													minWidth : 200,
													modal : true,
													icon : Ext.Msg.INFO,
													buttons : Ext.Msg.OK
												});
											}
										});
									}
								}
							}
						} ]
					}, {
						columnWidth : .4,
						id : "D001",
						xtype : "form",
						fileUpload : true,
						labelWidth: 125,
						layout : "form",
						items : [ {
							id : "D001selectFile",
							fieldLabel : "美元汇总D001",
							xtype : "fileuploadfield",
							emptyText : "请选择文件",
							name : "file",
							anchor : "95%"
						}, {
							xtype : "textfield",
							name : "type",
							hidden : true,
							value : "D001"
						} ]
					}, {
						columnWidth : .1,
						layout : "form",
						items : [ {
							xtype : "button",
							text : "上传文件",
							handler : function() {
								var vD = Ext.getCmp("D001selectFile").getValue();
								if(''==vD){
									Ext.Msg.show({
										title: "Selected File",
							            msg: vD&&vD!='' ? vD:'未选择文件!',
							            minWidth: 200,
							            modal: true,
							            icon: Ext.Msg.INFO,
							            buttons: Ext.Msg.OK
									});
									return;
								}else{
									if (Ext.getCmp("D001").getForm().isValid()) {
										Ext.getCmp("D001").getForm().submit( {
											url : "upload2.action",
											waitMsg : "正在上传文件...",
											success : function(fp, o) {
												Ext.Msg.show( {
													title : "Success",
													msg : "文件上传成功！",
													minWidth : 200,
													modal : true,
													icon : Ext.Msg.INFO,
													buttons : Ext.Msg.OK
												});
											}
										});
									}
								}
							}
						} ]
					}, {
						columnWidth : .4,
						id : "E002",
						xtype : "form",
						fileUpload : true,
						labelWidth: 125,
						layout : "form",
						items : [ {
							id : "E002selectFile",
							fieldLabel : "美元交易明细E002",
							xtype : "fileuploadfield",
							emptyText : "请选择文件",
							name : "file",
							anchor : "95%"
						}, {
							xtype : "textfield",
							name : "type",
							hidden : true,
							value : "E002"
						} ]
					}, {
						columnWidth : .1,
						layout : "form",
						items : [ {
							xtype : "button",
							text : "上传文件",
							handler : function() {
								var vE2 = Ext.getCmp("E002selectFile").getValue();
								if(''==vE2){
									Ext.Msg.show({
										title: "Selected File",
							            msg: vE2&&vE2!='' ? vE2:'未选择文件!',
							            minWidth: 200,
							            modal: true,
							            icon: Ext.Msg.INFO,
							            buttons: Ext.Msg.OK
									});
									return;
								}else{
									if (Ext.getCmp("E002").getForm().isValid()) {
										Ext.getCmp("E002").getForm().submit( {
											url : "upload2.action",
											waitMsg : "正在上传文件...",
											success : function(fp, o) {
												Ext.Msg.show( {
													title : "Success",
													msg : "文件上传成功！",
													minWidth : 200,
													modal : true,
													icon : Ext.Msg.INFO,
													buttons : Ext.Msg.OK
												});
											}
										});
									}
								}
							}
						} ]
					}, {
						columnWidth : .4,
						id : "E001",
						xtype : "form",
						fileUpload : true,
						labelWidth: 125,
						layout : "form",
						items : [ {
							id : "E001selectFile",
							fieldLabel : "美元汇总明细E001",
							xtype : "fileuploadfield",
							emptyText : "请选择文件",
							name : "file",
							anchor : "95%"
						}, {
							xtype : "textfield",
							name : "type",
							hidden : true,
							value : "E001"
						} ]
					}, {
						columnWidth : .1,
						layout : "form",
						items : [ {
							xtype : "button",
							text : "上传文件",
							handler : function() {
								var vE = Ext.getCmp("E001selectFile").getValue();
								if(''==vE){
									Ext.Msg.show({
										title: "Selected File",
							            msg: vE&&vE!='' ? vE:'未选择文件!',
							            minWidth: 200,
							            modal: true,
							            icon: Ext.Msg.INFO,
							            buttons: Ext.Msg.OK
									});
									return;
								}else{
									if (Ext.getCmp("E001").getForm().isValid()) {
										Ext.getCmp("E001").getForm().submit( {
											url : "upload2.action",
											waitMsg : "正在上传文件...",
											success : function(fp, o) {
												Ext.Msg.show( {
													title : "Success",
													msg : "文件上传成功！",
													minWidth : 200,
													modal : true,
													icon : Ext.Msg.INFO,
													buttons : Ext.Msg.OK
												});
											}
										});
									}
								}
							}
						} ]
					}]
				}, {
					xtype : "fieldset",
					title : "积分",
					layout : "column",
					items : [ {
						columnWidth : .4,
						id : "G001",
						xtype : "form",
						fileUpload : true,
						labelWidth: 125,
						layout : "form",
						items : [ {
							id : "G001selectFile",
							fieldLabel : "携程积分数据上传",
							xtype : "fileuploadfield",
							emptyText : "请选择文件",
							name : "file",
							anchor : "95%"
						}, {
							xtype : "textfield",
							name : "type",
							hidden : true,
							value : "G001"
						} ]
					}, {
						columnWidth : .1,
						layout : "form",
						items : [ {
							xtype : "button",
							text : "上传文件",
							handler : function() {
								var vG = Ext.getCmp("G001selectFile").getValue();
								if(''==vG){
									Ext.Msg.show({
										title: "Selected File",
							            msg: vG&&vG!='' ? vG:'未选择文件!',
							            minWidth: 200,
							            modal: true,
							            icon: Ext.Msg.INFO,
							            buttons: Ext.Msg.OK
									});
									return;
								}else{
									if (Ext.getCmp("G001").getForm().isValid()) {
										Ext.getCmp("G001").getForm().submit( {
											url : "upload2.action",
											waitMsg : "正在上传文件...",
											success : function(fp, o) {
												Ext.Msg.show( {
													title : "Success",
													msg : "文件上传成功！",
													minWidth : 200,
													modal : true,
													icon : Ext.Msg.INFO,
													buttons : Ext.Msg.OK
												});
											}
										});
									}
								}
							}
						} ]
					}, {
						columnWidth : .4,
						id : "G002",
						xtype : "form",
						fileUpload : true,
						labelWidth: 125,
						layout : "form",
						items : [ {
							id : "G002selectFile",
							fieldLabel : "万里通积分数据上传",
							xtype : "fileuploadfield",
							emptyText : "请选择文件",
							name : "file",
							anchor : "95%"
						}, {
							xtype : "textfield",
							name : "type",
							hidden : true,
							value : "G002"
						} ]
					}, {
						columnWidth : .1,
						layout : "form",
						items : [ {
							xtype : "button",
							text : "上传文件",
							handler : function() {
								var vG2 = Ext.getCmp("G002selectFile").getValue();
								if(''==vG2){
									Ext.Msg.show({
										title: "Selected File",
							            msg: vG2&&vG2!='' ? vG2:'未选择文件!',
							            minWidth: 200,
							            modal: true,
							            icon: Ext.Msg.INFO,
							            buttons: Ext.Msg.OK
									});
									return;
								}else{
									if (Ext.getCmp("G002").getForm().isValid()) {
										Ext.getCmp("G002").getForm().submit( {
											url : "upload2.action",
											waitMsg : "正在上传文件...",
											success : function(fp, o) {
												Ext.Msg.show( {
													title : "Success",
													msg : "文件上传成功！",
													minWidth : 200,
													modal : true,
													icon : Ext.Msg.INFO,
													buttons : Ext.Msg.OK
												});
											}
										});
									}
								}
							}
						} ]
					} ]
				}, {
					xtype : "fieldset",
					title : "个性化",
					layout : "column",
					items : [{
						columnWidth : .4,
						id : "H001",
						xtype : "form",
						fileUpload : true,
						labelWidth: 125,
						layout : "form",
						items:[{
							id : "H001selectFile",
							fieldLabel : "个性化数据H001",
							xtype : "fileuploadfield",
							emptyText : "请选择文件",
							name : "file",
							anchor : "95%"
						}, {
							xtype : "textfield",
							name : "type",
							hidden : true,
							value : "H001"
						} ]
					}, {
						columnWidth : .1,
						layout : "form",
						items :[{
							xtype : "button",
							text : "上传文件",
							handler : function() {
								var vH = Ext.getCmp("H001selectFile").getValue();
								if(''==vH){
									Ext.Msg.show({
										title: "Selected File",
							            msg: vH&&vH!='' ? vH:'未选择文件!',
							            minWidth: 200,
							            modal: true,
							            icon: Ext.Msg.INFO,
							            buttons: Ext.Msg.OK
									});
									return;
								}else{
									if (Ext.getCmp("H001").getForm().isValid()) {
										Ext.getCmp("H001").getForm().submit( {
											url : "upload2.action",
											waitMsg : "正在上传文件...",
											success : function(fp, o) {
												Ext.Msg.show( {
													title : "Success",
													msg : "文件上传成功！",
													minWidth : 200,
													modal : true,
													icon : Ext.Msg.INFO,
													buttons : Ext.Msg.OK
												});
											}
										});
									}
								}
							}
						} ]
					}]
				}]
		});
		
		var upload_pel = new Ext.Panel( {
			id : "myPanel",
			layout : "border",
			border:false,
			buttonAlign: "center",
			buttons:[{
				id: "parseButton",
				text : "导入上传的文件",
				width : 250,
				handler : function() {
					Ext.Ajax.request({
						url : 'upload2!parseFile.action',
						waitMsg : "正在解析文件...",
						success : function(fp, o){
							if(null==fp || fp.responseText=='' ){
								Ext.Msg.show( {
									title : 'Success',
									msg : "文件解析成功！",
									minWidth : 200,
									modal : true,
									icon : Ext.Msg.INFO,
									buttons : Ext.Msg.OK
								});
							//	Ext.getCmp("parseButton").setDisabled(true);
							}else{
								Ext.Msg.show( {
									title : 'Success',
									msg : fp.responseText,
									minWidth : 200,
									modal : true,
									icon : Ext.Msg.INFO,
									buttons : Ext.Msg.OK
								});
							}
						}
					});
				}
			},{
				id: "makeButton",
				text : "账单合成",
				width : 250,
				handler : function() {
					Ext.Ajax.request({
						url : 'work!make_composeXml.action',
						waitMsg : "正在合成账单...",
						success : function(fp, o){
							if(null==fp || fp.responseText=='' ){
								Ext.Msg.show( {
									title : 'Success',
									msg : "账单合成成功！",
									minWidth : 200,
									modal : true,
									icon : Ext.Msg.INFO,
									buttons : Ext.Msg.OK
								});
								Ext.getCmp("makeButton").setDisabled(true);
							}else if("null"==fp.responseText){
								Ext.Msg.show( {
									title : 'Error',
									msg : "合成失败！",
									minWidth : 200,
									modal : true,
									icon : Ext.Msg.INFO,
									buttons : Ext.Msg.OK
								});
							}
						}
					});
				}
			},{
				id: "queryButton",
				text : "查询合成的数据",
				width : 250,
				handler : function() {
					code_store.load({params: {start:0,limit:limit}});
				}
			}],
			items : [ uploadForm, dirGrid ]		
		});
	
	var CenterPanel=Ext.getCmp("CenterPanel");
	CenterPanel.removeAll();
	CenterPanel.add(upload_pel);
	CenterPanel.doLayout();	
</script>